import { UserModule } from '@/store/modules/user';

/**
 * CheackPermission 鉴权
 * @param {string[]} value ['roles'...]
 */
export const CheackPermission = (value: string[]): boolean => {
  const roles = UserModule.resourceKeys;
  if (value && value instanceof Array && value.length > 0) {
    const hasPermission = roles.some((role: string) => {
      return value.includes(role);
    });

    return hasPermission;
  } else {
    throw new Error(`无效规则! 请按照 ['roles'...]`);
  }
}
